package com.dinggou.shopjb.utils;

import com.dinggou.shopjb.constants.Constant;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class DataTimeUtils {

    private static SimpleDateFormat ymUnitFormat = new SimpleDateFormat("yyyy年MM月", Locale.CHINA);
    private static SimpleDateFormat ymdHmdataFromat = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
    private static SimpleDateFormat mdhmFormat = new SimpleDateFormat("MM-dd HH:mm", Locale.CHINA);

    public static String formatYMUnitTime(long dataTime) {
        return ymUnitFormat.format(new Date(dataTime));
    }

    public static String formatMDhmTime(long dataTime) {
        return mdhmFormat.format(new Date(dataTime));
    }

    public static String formatYHDHMTime(long dataTime) {
        return ymdHmdataFromat.format(new Date(dataTime));
    }

    public static boolean isRegTenDay(long regTime) {
        long regTenTime = regTime * 1000 + Constant.REG_TEN_TIME;
        if (regTenTime > System.currentTimeMillis()) {
            return true;
        }
        return false;
    }

    public static boolean isRegOverThreeDay(long regTime) {
        long regTenTime = regTime * 1000 + Constant.REG_TASK_CHANGE_NAME_TIME;
        if (System.currentTimeMillis() > regTenTime) {
            return true;
        }
        return false;
    }

    public static boolean isRegOverFiveDay(long regTime) {
        long regTenTime = regTime * 1000 + Constant.REG_TASK_NEWER_REMIND_TIME;
        if (System.currentTimeMillis() > regTenTime) {
            return true;
        }
        return false;
    }

    public static String getTimeStamp() {
        return String.valueOf(System.currentTimeMillis() / 1000);
    }

    public static String getHHMMTime(long time, boolean isMill) {
        Date date;
        if (isMill) {
            date = new Date(time);
        } else {
            date = new Date(time * 1000);
        }
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
        return sdf.format(date);
    }
}
